package com.wisty.finalproject;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.facebook.widget.ProfilePictureView;

public class CommentAdapter extends BaseAdapter {
	private ArrayList<CommentModel> list;

	private LayoutInflater myInflater;
	
	public CommentAdapter(Context c, ArrayList<CommentModel> list){
		this.list = list;
		myInflater = LayoutInflater.from(c);
	}
	
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}
	
	public void setList(ArrayList<CommentModel> list){
		this.list = list;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		convertView = myInflater.inflate(R.layout.comment_item, null);
		CommentModel comment = list.get(position);
		
		TextView nameView = (TextView) convertView.findViewById(R.id.comment_name);
		TextView dataView = (TextView) convertView.findViewById(R.id.comment_data);
		ProfilePictureView  userPictureView = (ProfilePictureView) convertView.findViewById(R.id.comment_picture);
		
		nameView.setText(comment.getUserName());
		dataView.setText(comment.getComment());
		userPictureView.setProfileId(comment.getUserId());
		
		
		return convertView;
	}

}
